package org.eclipse.wtp.sample.converter;

public class ConverterClass {
	private String type;		// The type of conversion (i.e. length, velocity, ext.)
	private double convertTo;	// The output number!
	private double convertFrom;	// This is the number I need to convert from
	private int    unitsTo;		// These are the units desired to convert to
	private int    unitsFrom;	// These are the original units
	private double disconv; 	// The value for converting meters to feet
	private String unitTo;		// Name of Unit
	private String unitFrom; 	// Name of unit
	// Constructor
	
	public ConverterClass(String type, double convertFrom, int unitsTo, int unitsFrom)
	{
		this.type=type;
		this.convertTo= 0.0;
		this.convertFrom = convertFrom;
		this.unitsTo= unitsTo;
		this.unitsFrom = unitsFrom;
		this.disconv = 3.2808399; // 1 meter = x feet
		this.unitTo="Hello";
		this.unitFrom="World";
		
	}
	public void setUnit(int unitsTo, int unitsFrom)
	{
		switch(unitsTo)
		{
		case 1:
			unitTo ="Meters";
			break;
		case 2:
			unitTo="Feet";
			break;
		case 3:
			unitTo="Celsius";
		case 4:
			unitTo="Fahrenheit";
			break;
		case 5:
			unitTo="Kelvin";
			break;
		case 6:
			unitTo="Kilogram";
			break;
		case 7:
			unitTo="Pounds";
			break;
		case 8:
			unitTo="Pascal";
			break;
		case 9:
			unitTo="Standard Atmosphere";
			break;
		case 10:
			unitTo="Meters/Second";
			break;
		case 11:
			unitTo="Feet/Second";
			break;
		case 12:
			unitTo="degree (angle)";
			break;
		case 13:
			unitTo="radian";
			break;
		case 14:
			unitTo="Binary";
			break;
		case 15:
			unitTo="Hexadecimal";
			break;
		case 16:
			unitTo="Decimal";
			break;
		}
		
		switch(unitsFrom)
		{
		case 1:
			unitFrom ="Meters";
			break;
		case 2:
			unitFrom="Feet";
			break;
		case 3:
			unitFrom="Celsius";
		case 4:
			unitFrom="Fahrenheit";
			break;
		case 5:
			unitFrom="Kelvin";
			break;
		case 6:
			unitFrom="Kilogram";
			break;
		case 7:
			unitFrom="Pounds";
			break;
		case 8:
			unitFrom="Pascal";
			break;
		case 9:
			unitFrom="Standard Atmosphere";
			break;
		case 10:
			unitFrom="Meters/Second";
			break;
		case 11:
			unitFrom="Feet/Second";
			break;
		case 12:
			unitFrom="degree (angle)";
			break;
		case 13:
			unitFrom="radian";
			break;
		case 14:
			unitFrom="Binary";
			break;
		case 15:
			unitFrom="Hexadecimal";
			break;
		case 16:
			unitFrom="Decimal";
			break;
		}
	}
	public void ConvertDistance(double convertFrom, int unitsTo,int unitsFrom)
	{
		// No convertion
		if(unitsTo== unitsFrom)
		{
			convertTo= convertFrom;
		}
		// Meters To Feet
		else if(unitsTo==1)
		{
			if(unitsFrom != 2)
			{
				
			}
			convertTo= convertFrom / disconv;
			//Feet to Meters
			
		}// Meters to Feet
		else if(unitsTo == 2)
		{
			if(unitsFrom !=1)
			{
				//Report Error
			}
			convertTo= convertFrom * disconv;
		}
	}
	public void tempconv(double convertFrom, int unitsFrom, int unitsTo)
	{
		if(unitsFrom==unitsTo)
		{
			convertTo= convertFrom;
		}
		// Celcius
		else if(unitsFrom==3)
		{
			// C to F
			if(unitsTo == 4)
			{
				//°C  x  9/5 + 32 = °F
				convertTo= (convertFrom * (9.0/5.0)) + 32;
			} // C to K
			else if(unitsTo == 5)
			{
				//K = C + 273
				convertTo= convertFrom +273;
			}
			else
			{
				//TODO:Report ERROR
			}			
		} // F TO
		else if(unitsFrom==4)
		{
			// F to C
			if(unitsTo == 3)
			{
				// (°F  -  32)  x  5/9 = °C
				convertTo= (convertFrom - 32.0) * (5.0/9.0);
			} // F to K
			else if(unitsTo == 5)
			{
				convertTo=(convertFrom * (9.0/5.0)) + 32; // now in C
				convertTo+=273; // now in K
			}
			else
			{
				//TODO: Report ERROR
			}
		}// K to 
		else if (unitsFrom == 5)
		{
			//K to C
			if(unitsTo == 3)
			{
				convertTo=convertFrom -273;
			}//K to F
			else if(unitsTo == 4)
			{
				convertTo=convertFrom -273;
				convertTo= (convertTo * (9.0/5.0))+32;
			}			
			else
			{
				//TODO: REPORT ERROR
			}
		}
		else 
		{
			//TODO: REport ERROR
		}
	}
	public void ConvertMass(double convertFrom, int unitsFrom, int unitsTo)
	{
		if(unitsFrom==unitsTo)
		{
			convertTo = convertFrom;
		}//KiloGram to Pound
		else if( unitsFrom==6)
		{
			if(unitsTo != 7)
			{
				//TODO: Report ERROR
			}
			convertTo= convertFrom * 2.20462262;
		}
		else if( unitsFrom ==7)
		{
			if(unitsTo != 6)
			{
				//TODO: REport Error
			}
			convertTo= convertFrom /2.20462262;
		}
	}
	public void ConvertVelocity(double convertFrom, int unitsFrom, int unitsTo)
	{
		if(unitsFrom== unitsTo)
		{
			convertTo= convertFrom;
		}// Meters/S to FT/S
		else if(unitsFrom== 10)
		{
			if(unitsTo!= 11)
			{
				//TODO: report ERROR
			}
			//(ft/s) * 0.3048 = (m/s)
			convertTo= convertFrom * 0.3048;
		}
		else if(unitsFrom== 11)
		{
			if(unitsTo!= 10)
			{
				//TODO: REport Error
			}
			convertTo= convertFrom/ 0.3048;
		}
	}
	public void ConvertAngle(double convertFrom, int unitsFrom, int unitsTo)
	{
		if(unitsFrom== unitsTo)
		{
			convertTo=convertFrom;
		}// Deg to Rad
		else if(unitsFrom == 12)
		{
			if(unitsTo!= 13)
			{
				//TODO: Report ERROR
			}
			convertTo=convertFrom * 0.01745329;
		}
		else if(unitsFrom ==13)
		{
			if(unitsTo != 12)
			{
				//TODO report ERROR
			}
			convertTo=convertFrom / 0.01745329;
		}
	}
	public void ConvertNumaric(double convertFrom, int unitsFrom, int unitsTo)
	{
		if(unitsFrom== unitsTo)
			convertTo=convertFrom;
		else if(unitsFrom==14)
		{
			//Binary to Hex
			if(unitsTo== 15)
			{
				
			}
		}
	}
	// Getters and Setters For each Variable

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public double getConvertTo() {
		return convertTo;
	}

	public void setConvertTo(double convertTo) {
		this.convertTo = convertTo;
	}

	public double getConvertFrom() {
		return convertFrom;
	}

	public void setConvertFrom(double convertFrom) {
		this.convertFrom = convertFrom;
	}

	public int getUnitsTo() {
		return unitsTo;
	}

	public void setUnitsTo(int unitsTo) {
		this.unitsTo = unitsTo;
	}

	public int getUnitsFrom() {
		return unitsFrom;
	}

	public void setUnitsFrom(int unitsFrom) {
		this.unitsFrom = unitsFrom;
	}
	
}
